/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package avl.sv.shared.model.classifier;

import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;
import libsvm.svm_parameter;

/**
 *
 * @author benbryan
 */
public class OptionsPromptSVM extends javax.swing.JPanel implements ClassifierOptionsPromptInterface{
    ClassifierSVM classifierSVM = null;
    
    int numelFeatures = 1;
    public OptionsPromptSVM(ClassifierSVM classifierSVM) {
        this.classifierSVM = classifierSVM;
        setupLookAndFeel();
        initComponents();
        setSVMparam();
    }
    
    @Override
    public AbstractClassifier getClassifier() {
        getSVMparam();
        return classifierSVM;
    }

    @Override
    public void setNumelFeatures(int numel) {
        numelFeatures = numel;
    }
    
    private void setupLookAndFeel() {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
        }
    }
        
    private void setSVMparam(){
        jCheckBoxSVM_GammaAuto.setSelected(classifierSVM.autoGamma);
        svm_parameter params = classifierSVM.param;
        jComboBoxKernelType.setSelectedIndex(                   params.kernel_type);
        jComboBoxSVM_Type.setSelectedIndex(                     params.svm_type);
        jTextFieldCacheSize.setText(String.valueOf(             params.cache_size));
        jTextFieldCoefficient0.setText(String.valueOf(          params.coef0));
        jTextFieldCost.setText(String.valueOf(                  params.C));
        jTextFieldDegree.setText(String.valueOf(                params.degree));
        jTextFieldEpsilon.setText(String.valueOf(               params.p));
        jCheckBoxSVM_GammaAuto.setSelected(classifierSVM.autoGamma);
        if (jCheckBoxSVM_GammaAuto.isSelected()) {
            jTextFieldGamma.setText(String.valueOf(getDefaultSVM_Gamma()));
        } else {
            jTextFieldGamma.setText(String.valueOf(params.gamma));
        }
        jTextFieldNU.setText(String.valueOf(                    params.nu));
        jTextFieldProbabilityEstimates.setText(String.valueOf(  params.probability));
        jTextFieldShrinking.setText(String.valueOf(             1==params.shrinking));
        jTextFieldTolerance.setText(String.valueOf(             params.eps));
        jTextFieldNR_Weight.setText(String.valueOf(             params.nr_weight));
    }

    private void getSVMparam() {
        classifierSVM.autoGamma = jCheckBoxSVM_GammaAuto.isSelected();
        svm_parameter p = new svm_parameter();

        // default values
        p.svm_type = jComboBoxSVM_Type.getSelectedIndex();
        p.kernel_type = jComboBoxKernelType.getSelectedIndex();
        p.degree = Integer.valueOf(jTextFieldDegree.getText());
        p.gamma = Double.valueOf(jTextFieldGamma.getText());
        p.coef0 = Double.valueOf(jTextFieldCoefficient0.getText());
        p.nu = Double.valueOf(jTextFieldNU.getText());
        p.cache_size = Double.valueOf(jTextFieldCacheSize.getText());
        p.C = Double.valueOf(jTextFieldCost.getText());
        p.eps = Double.valueOf(jTextFieldTolerance.getText());
        p.p = Double.valueOf(jTextFieldEpsilon.getText());
        p.shrinking = Integer.valueOf(Boolean.valueOf(jTextFieldShrinking.getText()) ? 1 : 0);
        p.probability = Integer.valueOf(jTextFieldProbabilityEstimates.getText());
        p.nr_weight = Integer.valueOf(jTextFieldNR_Weight.getText());
        p.weight_label = new int[0];
        p.weight = new double[0];
        classifierSVM.param = p;
    }

    private double getDefaultSVM_Gamma(){
        return 1 / (double)numelFeatures;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jComboBoxKernelType = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldDegree = new javax.swing.JTextField();
        jTextFieldCoefficient0 = new javax.swing.JTextField();
        jTextFieldGamma = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jCheckBoxSVM_GammaAuto = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jComboBoxSVM_Type = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldCost = new javax.swing.JTextField();
        jTextFieldNU = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldEpsilon = new javax.swing.JTextField();
        jTextFieldCacheSize = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldTolerance = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jTextFieldShrinking = new javax.swing.JTextField();
        jTextFieldProbabilityEstimates = new javax.swing.JTextField();
        jTextFieldNR_Weight = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jComboBoxKernelType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Linear", "Polynomial", "RBF", "Sigmoid" }));
        jComboBoxKernelType.setSelectedIndex(2);
        jComboBoxKernelType.setToolTipText("kernel_type : set type of kernel function\n\tlinear: u'*v\n\tpolynomial: (gamma*u'*v + coef0)^degree\n\tradial basis function: exp(-gamma*|u");
        jComboBoxKernelType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxKernelTypeActionPerformed(evt);
            }
        });

        jLabel2.setText("Type");

        jLabel4.setText("Degree");

        jLabel5.setText("Coefficient 0");

        jTextFieldDegree.setText("3");
        jTextFieldDegree.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldDegreeFocusLost(evt);
            }
        });

        jTextFieldCoefficient0.setText("0");
        jTextFieldCoefficient0.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCoefficient0FocusLost(evt);
            }
        });

        jTextFieldGamma.setText("0");
        jTextFieldGamma.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldGammaFocusLost(evt);
            }
        });

        jLabel15.setText("Gamma");

        jLabel16.setText("Auto");

        jCheckBoxSVM_GammaAuto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxSVM_GammaAutoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addComponent(jCheckBoxSVM_GammaAuto))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBoxKernelType, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldDegree, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldCoefficient0, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldGamma, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxKernelType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldDegree, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldCoefficient0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)))
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxSVM_GammaAuto)
                    .addComponent(jTextFieldGamma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(11, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(95, 95, 95)
                .addComponent(jLabel15)
                .addGap(14, 14, 14))
        );

        jLabel3.setText("Kernel Parameters");

        jLabel6.setText("General Parameters");

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jComboBoxSVM_Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "C-SVC", "nu-SVC", "One-class SVM", "Epsilon-SVR", "nu-SVR" }));
        jComboBoxSVM_Type.setToolTipText("svm_type : set type of SVM\n\tC-SVC\n\tnu-SVC\n\tone-class SVM\n\tepsilon-SVR\n\tnu-SVR");
        jComboBoxSVM_Type.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSVM_TypeActionPerformed(evt);
            }
        });

        jLabel1.setText("SVM_Type");

        jTextFieldCost.setText("1");
        jTextFieldCost.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCostFocusLost(evt);
            }
        });

        jTextFieldNU.setText("0.5");
        jTextFieldNU.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldNUFocusLost(evt);
            }
        });

        jLabel7.setText("Cost ");

        jTextFieldEpsilon.setText("0.1");
        jTextFieldEpsilon.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldEpsilonFocusLost(evt);
            }
        });

        jTextFieldCacheSize.setText("100");
        jTextFieldCacheSize.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCacheSizeFocusLost(evt);
            }
        });

        jLabel8.setText("nu ");

        jLabel9.setText("Epsilon ");

        jLabel10.setText("Cachesize ");

        jTextFieldTolerance.setText("0.001");
        jTextFieldTolerance.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldToleranceFocusLost(evt);
            }
        });

        jLabel11.setText("Tolerance ");

        jTextFieldShrinking.setText("true");
        jTextFieldShrinking.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldShrinkingFocusLost(evt);
            }
        });

        jTextFieldProbabilityEstimates.setText("0");
        jTextFieldProbabilityEstimates.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldProbabilityEstimatesFocusLost(evt);
            }
        });

        jTextFieldNR_Weight.setText("1");
        jTextFieldNR_Weight.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldNR_WeightFocusLost(evt);
            }
        });

        jLabel12.setText("Shrinking");

        jLabel13.setText("P. E.");

        jLabel14.setText("nr Weight");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBoxSVM_Type, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldCost, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldNU, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldEpsilon, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldCacheSize, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldTolerance, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldShrinking, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldProbabilityEstimates, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldNR_Weight, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxSVM_Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNU, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldEpsilon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(8, 8, 8)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCacheSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldTolerance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldShrinking, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldProbabilityEstimates, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNR_Weight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(13, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBoxKernelTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxKernelTypeActionPerformed

    }//GEN-LAST:event_jComboBoxKernelTypeActionPerformed

    private void jTextFieldDegreeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDegreeFocusLost
        JTextField jText = (JTextField) evt.getSource();
        int d = 3;
        try {
            d = Integer.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldDegreeFocusLost

    private void jTextFieldCoefficient0FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCoefficient0FocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = 0;
        try {
            d = Double.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldCoefficient0FocusLost

    private void jTextFieldGammaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldGammaFocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = getDefaultSVM_Gamma();
        try {
            d = Double.valueOf(jText.getText());
            if (d == 0) {
                d = 0.5;
            }
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldGammaFocusLost

    private void jCheckBoxSVM_GammaAutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSVM_GammaAutoActionPerformed
        if (jCheckBoxSVM_GammaAuto.isSelected()){
            jTextFieldGamma.setText(String.valueOf(getDefaultSVM_Gamma()));
        }
    }//GEN-LAST:event_jCheckBoxSVM_GammaAutoActionPerformed

    private void jComboBoxSVM_TypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSVM_TypeActionPerformed

    }//GEN-LAST:event_jComboBoxSVM_TypeActionPerformed

    private void jTextFieldCostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCostFocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = 1;
        try {
            d = Double.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldCostFocusLost

    private void jTextFieldNUFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldNUFocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = 0.5;
        try {
            d = Double.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldNUFocusLost

    private void jTextFieldEpsilonFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldEpsilonFocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = 0.1;
        try {
            d = Double.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldEpsilonFocusLost

    private void jTextFieldCacheSizeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCacheSizeFocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = 100;
        try {
            d = Double.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldCacheSizeFocusLost

    private void jTextFieldToleranceFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldToleranceFocusLost
        JTextField jText = (JTextField) evt.getSource();
        double d = 0.001;
        try {
            d = Double.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldToleranceFocusLost

    private void jTextFieldShrinkingFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldShrinkingFocusLost
        JTextField jText = (JTextField) evt.getSource();
        boolean d = true;
        try {
            d = Boolean.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldShrinkingFocusLost

    private void jTextFieldProbabilityEstimatesFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldProbabilityEstimatesFocusLost
        JTextField jText = (JTextField) evt.getSource();
        int d = 0;
        try {
            d = Integer.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldProbabilityEstimatesFocusLost

    private void jTextFieldNR_WeightFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldNR_WeightFocusLost
        JTextField jText = (JTextField) evt.getSource();
        int d = 1;
        try {
            d = Integer.valueOf(jText.getText());
        } catch (NumberFormatException ex) {
        } finally {
            jText.setText(String.valueOf(d));
        }
    }//GEN-LAST:event_jTextFieldNR_WeightFocusLost

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox jCheckBoxSVM_GammaAuto;
    private javax.swing.JComboBox jComboBoxKernelType;
    private javax.swing.JComboBox jComboBoxSVM_Type;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextFieldCacheSize;
    private javax.swing.JTextField jTextFieldCoefficient0;
    private javax.swing.JTextField jTextFieldCost;
    private javax.swing.JTextField jTextFieldDegree;
    private javax.swing.JTextField jTextFieldEpsilon;
    private javax.swing.JTextField jTextFieldGamma;
    private javax.swing.JTextField jTextFieldNR_Weight;
    private javax.swing.JTextField jTextFieldNU;
    private javax.swing.JTextField jTextFieldProbabilityEstimates;
    private javax.swing.JTextField jTextFieldShrinking;
    private javax.swing.JTextField jTextFieldTolerance;
    // End of variables declaration//GEN-END:variables

}
